<?php
class Cms_PageController extends Zend_Controller_Action {
    private $_languages = array();
    public function init() {
        $this->_languages = Utils_Global::getSupportLanguages();
    }
    
	public function pageAction() {
	    $id = Utils_Global::$params['id'];
	    $lang = Utils_Global::$params['lang'];
	    $popup = Utils_Global::$params['popup'];
	    if(!in_array($lang, $this->_languages)) {
	    	$lang = Utils_Global::getCurrentLanguage();
	    }
	    $model = Cms_Model_Page::factory();
	    $options = array('id' => $id, 'lang' => $lang);
	    $page = $model->select($options);
	    if($page) {
	        $page = $page[0];
	    }
	    if($popup == 1) {
	        $this->_helper->json($page);
	    }
	    
	    $breadcrumbData = array(
	    		array('url' => $this->view->serverUrl(),
	    				'displayName' => $this->view->translate('home', $lang),
	    				'title' => $this->view->translate('home', $lang),
	    		),
	    		array(
	    				'url' => 'javascript:void(0)',
	    				'displayName' => $page["title"],
	    				'title' => $page["title"],
	    		),
	    );
	    
	    $this->view->breadcrumb = $breadcrumbData;
// 	    prBinh($id);
	    if($id == 3) {
	        $this->view->metadata = $this->view->metadata('question_submition', array('title' => $this->view->translate('seo_schedule_title', $lang),
	        		                                                                    'description' => $this->view->translate('seo_schedule_description', $lang),
	        ),$this->view->serverUrl() . $this->view->url(array()));
	    } else if($id == 5) {
	        $this->view->metadata = $this->view->metadata('question_submition', array('title' => $this->view->translate('seo_page_downloadbrochure_title', $lang),
	        		'description' => $this->view->translate('seo_page_downloadbrochure_description', $lang),
	        ),$this->view->serverUrl() . $this->view->url(array()));
	    } else if($id==6) {
	        $this->view->metadata = $this->view->metadata('question_submition', array('title' => $this->view->translate('seo_page_giai_thuong_title', $lang),
	        		'description' => $this->view->translate('seo_page_giai_thuong_description', $lang),
	        ),$this->view->serverUrl() . $this->view->url(array()));
	    } else if($id == 7) {
	        $this->view->metadata = $this->view->metadata('question_submition', array('title' => $this->view->translate('seo_page_hoi_thao_title', $lang),
	        		'description' => $this->view->translate('seo_page_hoi_thao_description', $lang),
	        ),$this->view->serverUrl() . $this->view->url(array()));
	    } else if($id == 9) {
	        $this->view->metadata = $this->view->metadata('question_submition', array('title' => $this->view->translate('seo_page_hoc_bong_title', $lang),
	        		'description' => $this->view->translate('seo_page_hoc_bong_description', $lang),
	        ),$this->view->serverUrl() . $this->view->url(array()));
	    } else {
        	    $this->view->metadata = $this->view->metadata('question_submition', array('title' => $page['title'],
        	                                                                                'description' => '',
        	    ),$this->view->serverUrl() . $this->view->url(array()));
	    }
	    $this->view->lang = $lang;
	    $this->view->page = $page;
	    
	    if($id == 3) {
	        Utils_Global::$params['schedulingclzz'] = 'current';
	    }
	}
	
	public function introductionAction() {
		$id1 = Utils_Global::$params['id1'];
		$id2 = Utils_Global::$params['id2'];
		$lang = Utils_Global::$params['lang'];
		if(!in_array($lang, $this->_languages)) {
			$lang = Utils_Global::getCurrentLanguage();
		}
		$model = Cms_Model_Page::factory();
		$options = array('id' => $id1, 'lang' => $lang);
		$page1 = $model->select($options);
		if($page1) {
			$page1 = $page1[0];
		}
		$options = array('id' => $id2, 'lang' => $lang);
		$page2 = $model->select($options);
		if($page2) {
		    $page2 = $page2[0];
		}
		$breadcrumbData = array(
				array('url' => $this->view->serverUrl(),
						'displayName' => $this->view->translate('home', $lang),
						'title' => $this->view->translate('home', $lang),
				),
				array(
						'url' => 'javascript:void(0)',
						'displayName' => $this->view->translate('page_introduction', $lang),
						'title' => $this->view->translate('page_introduction', $lang),
				),
		);
	
		$this->view->breadcrumb = $breadcrumbData;
		$this->view->metadata = $this->view->metadata('fmit_introduction', array('title' => $this->view->translate('fmit_home_introduction_title', $lang),
                                                                            'description' => $this->view->translate('fmit_home_introduction_description', $lang),
		),
				$this->view->serverUrl() . $this->view->url(array()));
		$this->view->lang = $lang;
		$this->view->page1 = $page1;
		$this->view->page2 = $page2;
		Utils_Global::$params['introductionclzz'] = 'current';
	}
	
}
